import Vue from 'vue'
//全局方法，在created里面去调用事件会报错,公用方法
var comsys = {
  install(Vue) {
    Vue.prototype.comsys = {
      // val: true
      val: function(val) {
        return val
      },
      //通用时间格式转化器
      getFormatDate(date) {
        var seperator1 = '-'
        var year = date.getFullYear()
        var month = date.getMonth() + 1
        var strDate = date.getDate()
        if (month >= 1 && month <= 9) {
          month = '0' + month
        }
        if (strDate >= 0 && strDate <= 9) {
          strDate = '0' + strDate
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate
        return currentdate
      },
      //获取当前时间
      getNowFormatDate() {
        var date = new Date()
        var seperator1 = '-'
        var year = date.getFullYear()
        var month = date.getMonth() + 1
        var strDate = date.getDate()
        if (month >= 1 && month <= 9) {
          month = '0' + month
        }
        if (strDate >= 0 && strDate <= 9) {
          strDate = '0' + strDate
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate
        return currentdate
      }
    }
    //全局变量
    Vue.prototype.testname = '阿联'
  }
}
Vue.use(comsys)
//时间格式转换器
// getNowFormatDate() {
//   var date = new Date()
//   var seperator1 = '-'
//   var year = date.getFullYear()
//   var month = date.getMonth() + 1
//   var strDate = date.getDate()
//   if (month >= 1 && month <= 9) {
//     month = '0' + month
//   }
//   if (strDate >= 0 && strDate <= 9) {
//     strDate = '0' + strDate
//   }
//   var currentdate = year + seperator1 + month + seperator1 + strDate
//   return currentdate
// },
//通用时间格式转换器
// getFormatDate(date) {
//   var seperator1 = '-'
//   var year = date.getFullYear()
//   var month = date.getMonth() + 1
//   var strDate = date.getDate()
//   if (month >= 1 && month <= 9) {
//     month = '0' + month
//   }
//   if (strDate >= 0 && strDate <= 9) {
//     strDate = '0' + strDate
//   }
//   var currentdate = year + seperator1 + month + seperator1 + strDate
//   return currentdate
// },
